﻿#include <iostream>
#include "CServer.h"
#include <csignal>
#include <thread>
#include <mutex>
#include "IOServicePool.h"

int main()
{
    try {
        auto& pool = AsioIOServicePool::GetInstance();  //pool处理收发消息
        boost::asio::io_context ioc;   //ioc处理接收连接
        boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
        signals.async_wait([&ioc, &pool](auto, auto) {  //捕获几个信号，lambda里加几个参数
            ioc.stop();
            pool.Stop();
            });
        CServer s(ioc, 10086);
        ioc.run();
    }
    catch (exception& e) {
        std::cerr << "error:" << e.what() << endl;
    }
}

